//导入request
import request from '@/utils/request.js'

//调用接口函数
// export const userRegisterService = (registerData) =>{
//     const params = new URLSearchParams()
//     for(let key in registerData){
//         params.append(key,registerData[key])
//     }
//     return request.post('/user/register',params);
// }

//获取用户详细信息
// export const userInfoService = ()=>{
//     return request.get('/user/userInfo')
// }

export const userInfoById = (id)=>{
    return request.get('/user/userInfoById?id='+id)
}
//获取用户列表
export const userListService = (params)=>{
    return request.get('/user/list',{params:params})
}

//修改个人信息
export const userInfoUpdateService = (userInfoData)=>{
    return request.put('/user/update',userInfoData)
}

//修改头像
export const userAvatarUpdateService = (avatarUrl)=>{
    const params = new URLSearchParams();
    params.append('avatarUrl',avatarUrl)
    return request.patch('/user/updateAvatar',params)
}
//修改用户密码
import axios from 'axios';
import { useTokenStore } from '@/stores/token';

export const userPasswordUpdateService = async (data) => {
    const tokenStore = useTokenStore();
    const config = {
        headers: {
            'Authorization': `Bearer ${tokenStore.token}`
        }
    };
    return request.patch('/user/updatePwd', data, config);
};
//更新用户权限状态
export const userPowerUpdateService = (id,userPower)=>{
    const params = new URLSearchParams();
    params.append('id',id)
    params.append('userPower',userPower)
    return request.patch('/user/updatePower',params)
}